package org.example.controller;

import org.example.domain.Result;
import org.example.dto.RankingDto;
import org.example.service.RankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @FileName RankingController
 * @Description 内容排行榜
 * @Author coderfun
 * @selfDesc coding in fun
 * @date 2024-11-04
 **/
@RestController
@RequestMapping("/ranking")
public class RankingController {
    @Autowired
    private RankingService rankingService;

    @PostMapping("/add")
    public Result add(@RequestBody RankingDto rankingDto) {
        return rankingService.add(rankingDto) ? Result.success() : Result.fail();
    }

    @PostMapping("/select")
    public Result select() {
        return Result.success(rankingService.select());
    }

    @PostMapping("/selectMy")
    public Result selectMyRanking(RankingDto rankingDto) {
        return Result.success(rankingService.selectMyRanking(rankingDto));
    }
}
